﻿@using Volo.Abp.AspNetCore.Mvc.AntiForgery
@using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook
@using Lsw.Abp.AspNetCore.Mvc.UI.Theme.Stisla.Bundling
@using Lsw.Abp.AspNetCore.Mvc.Ui.Theme.Stisla.Themes.Stisla.Components.LeftNavbar
@using Lsw.Abp.AspNetCore.Mvc.UI.Theme.Stisla.Themes.Stisla.Components.PageAlerts
@using Lsw.Abp.AspNetCore.Mvc.Ui.Theme.Stisla.Themes.Stisla.Components.TopNavbar
@using Microsoft.Extensions.Localization
@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.MultiTenancy
@using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetScripts
@using Volo.Abp.AspNetCore.Mvc.UI.Widgets.Components.WidgetStyles
@using Volo.Abp.MultiTenancy
@inject IAbpAntiForgeryManager AbpAntiForgeryManager
@inject IBrandingProvider BrandingProvider
@inject IOptions<AbpMultiTenancyOptions> MultiTenancyOptions
@inject ICurrentTenant CurrentTenant
@inject IStringLocalizer<AbpUiMultiTenancyResource> MultiTenancyStringLocalizer
@inject ITenantResolveResultAccessor TenantResolveResultAccessor
@{
    Layout = null;
    AbpAntiForgeryManager.SetCookie();
    var containerClass = ViewBag.FluidLayout == true ? "container-fluid" : "container"; //TODO: Better and type-safe options
}

<!DOCTYPE html>
<html lang="@CultureInfo.CurrentCulture.Name">
<head>
    @await Component.InvokeLayoutHookAsync(LayoutHooks.Head.First, StandardLayouts.Account)
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
    <title>@(ViewBag.Title == null ? BrandingProvider.AppName : ViewBag.Title)</title>

    <abp-style-bundle name="@StislaThemeBundles.Styles.Global" />

    @await Component.InvokeAsync(typeof(WidgetStylesViewComponent))

    @await RenderSectionAsync("styles", false)

    @await Component.InvokeLayoutHookAsync(LayoutHooks.Head.Last, StandardLayouts.Account)

</head>

<body>
    @await Component.InvokeLayoutHookAsync(LayoutHooks.Body.First, StandardLayouts.Account)

    <div id="app">
        <div class="main-wrapper main-wrapper-1">
            <!-- Main Content -->
            <div>
                 <section class="section" style="width: 60%;margin-top: 10%;margin-left: auto;margin-right: auto">
                     <abp-row>
                         <div class="account-brand p-4 text-center mb-1">
                             <a alt="MyProjectName" class="navbar-brand" routerlink="/" href="/"></a><!---->
                         </div>
                         <abp-column size-md="_5" class="mx-auto">
                             @if (MultiTenancyOptions.Value.IsEnabled &&
                                  (TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(CookieTenantResolveContributor.ContributorName) == true))
                             {
                                 <div class="card shadow-sm rounded mb-3">
                                     <div class="card-body px-5">
                                         <div class="row">
                                             <div class="col">
                                                 <span style="font-size: .8em;" class="text-uppercase text-muted">@MultiTenancyStringLocalizer["Tenant"]</span><br/>
                                                 <h6 class="m-0 d-inline-block">
                                                     @if (CurrentTenant.Id == null)
                                                     {
                                                         <span>
                                                             @MultiTenancyStringLocalizer["NotSelected"]
                                                         </span>
                                                     }
                                                     else
                                                     {
                                                         <strong>@(CurrentTenant.Name ?? CurrentTenant.Id.Value.ToString())</strong>
                                                     }
                                                 </h6>
                                             </div>
                                             <div class="col-auto">
                                                 <a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm mt-3 btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a>
                                             </div>
                                         </div>
                                     </div>
                                 </div>
                             }
                             @(await Component.InvokeAsync<PageAlertsViewComponent>())
                             @RenderBody()
                         </abp-column>
                     </abp-row>
                </section>
            </div>
        </div>
    </div>

    <abp-script-bundle name="@StislaThemeBundles.Scripts.Global" />

    <script src="~/Abp/ApplicationConfigurationScript"></script>
    <script src="~/Abp/ServiceProxyScript"></script>

    @await RenderSectionAsync("scripts", false)

    @await Component.InvokeAsync(typeof(WidgetScriptsViewComponent))

    @await Component.InvokeLayoutHookAsync(LayoutHooks.Body.Last, StandardLayouts.Account)
</body>
</html>